/*
 * @lc app=leetcode.cn id=495 lang=javascript
 *
 * [495] 提莫攻击
 */

// @lc code=start
/**
 * @param {number[]} timeSeries
 * @param {number} duration
 * @return {number}
 */
var findPoisonedDuration = function (timeSeries, duration) {
  let sum = duration;
  for (let i = 0; i < timeSeries.length - 1; i++) {
    sum += Math.min(duration, timeSeries[i + 1] - timeSeries[i])
  }
  return sum;
};
// @lc code=end

